//
//  NavTitleView.m
//  HousingPoliceAssistant
//
//  Created by 云警01 on 2019/6/6.
//  Copyright © 2019 盛洋. All rights reserved.
//

#import "NavTitleView.h"
#import <QuartzCore/QuartzCore.h>

@implementation NavTitleView

@synthesize backBtn,titleLabel;


- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        backBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 50, self.frame.size.height)];
        [backBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
        backBtn.titleLabel.textAlignment = NSTextAlignmentLeft;
        [backBtn setTitleColor:COLOR_NAV_TITLE forState:UIControlStateNormal];
        backBtn.titleLabel.font = AutoLabFont2;
        [self addSubview:backBtn];

        titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, self.frame.size.height)];
        titleLabel.textAlignment = NSTextAlignmentCenter;
        titleLabel.font = AutoLabFont1;
        titleLabel.textColor = COLOR_NAV_TITLE;
        [self addSubview:titleLabel];
                
        _separatorLineView = [[UIView alloc] initWithFrame:CGRectMake(0, self.frame.size.height-1, SCREEN_W, 1)];
        _separatorLineView.backgroundColor = Base_lineColor;
        [self addSubview:_separatorLineView];
        
        [[NSBundle mainBundle]addObserver:self forKeyPath:@"titleBgColor" options:NSKeyValueObservingOptionNew context:nil];
    }
    return self;
}

- (void)dealloc
{
    [[NSBundle mainBundle]removeObserver:self forKeyPath:@"titleBgColor"];
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
    //    if ([keyPath isEqualToString:@"titleBgColor"]) {
    //        if ([(AppDelegate*)[UIApplication sharedApplication].delegate titleBgColor]) {
    //            self.backgroundColor = [NSBundle mainBundle].titleBgColor;
    //        }else {
    //            self.backgroundColor = COLOR_NAV_BG;
    //        }
    //    }
}

@end
